
<%@page import="com.lovo.vo.TreeNode"%>
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
List<TreeNode> list = (List<TreeNode>)request.getAttribute("list");

%>

<%!
	public String getsons(TreeNode root){
	String result = " ";
	if(root.getChildren().size()>0){
		result = result + "<ul>";
		for(TreeNode son:root.getChildren()){
			result = result+"<li>";
			result = result+"<a href=\"javascript:void(0);\"><span style='display:none'>"+son.getId()+"</span><span>"+son.getText()+"</span></a>";
			result = result + getsons(son);
			result = result+"</li>";
		}
		result = result + "</ul>";
	}
	return result;
	}

%>

<script type="text/javascript">
	$(document).ready(function(){
		$("#bul a").click(function(){
			
			var deptid = $(this).children().first().text();
			
			$("#deptid").val(deptid);
			$("#ad").attr("href","<%=basePath%>dept/addpop.do?deptid="+deptid+"");
			$("#del").attr("href","<%=basePath%>dept/del.do?deptid="+deptid+"");
		});
		
	});

	</script>
 <div class="pageHeader">
	<form onsubmit="return navTabSearch(this);" action="<%=basePath%>dept/find.do" method="post" id="xxxx" target="navTab">
	<div class="searchBar">
		<table class="searchContent">
			<tr>
				<td>
					搜索：<input type="text" name="dept" value="${requestScope.dept.dept }"/>
				</td>
				<td>
					<div class="button"><div class="buttonContent"><button value="search">查询</button></div></div>
				</td>
				<td>
					<input type="hidden" name="DEPT" value="" id="depthidden"/>
				</td>
				
			</tr>
		</table>
	</div>
	</form>
	<form onsubmit="return navTabSearch(this);" action="<%=basePath%>dept/getadd.do" method="post" id="deptform" >
	<input type="hidden" name="deptid" id="deptid"/>
	<div class="pageContent" id="treepage">
	<div class="panelBar">
		<ul class="toolBar">
			<li><a class="add" href="<%=basePath%>dept/addpop.do" target="dialog" mask="true" title="新增部门信息" id="ad"><span>添加</span></a></li>
			<li><a class="delete" href="<%=basePath%>dept/del.do" target="ajaxTodo" title="确定要删除吗?" id="del"><span>删除</span></a></li>
			<li class="line">line</li>
		</ul>
	</div>

 </div>
	</form>
</div>

<div style="float:left; display:block; margin:10px; overflow:auto; width:90%; height:80%; border:solid 1px #CCC; line-height:21px; background:#FFF;">
<%
	for(TreeNode root:list){
	%>
<ul class="tree treeFolder collapse" id="bul">
	<li><a href="javascript:void(0);" ><span style='display:none'><%= root.getId()%></span><span><%= root.getText()%></span></a>
	<%
		out.write(getsons(root));
	%>
	</li>
</ul>
<%
		}
	%>

</div>
  